export default (url) => {
    return new Promise(function (resolve, reject) {
        wx.getImageInfo({
            src: url,
            success: function (res) {
                console.log(res)
                wx.saveImageToPhotosAlbum({
                    filePath: res.path,
                    success: res => {
                        wx.showToast({
                            title: '保存成功'
                        })
                        resolve({
                            message: '保存成功',
                            detail: res
                        })
                    },
                    fail: e => {
                        console.error('下载图片出现错误', e)
                        reject(e)
                    }
                })
            },
            fail: e => {
                console.error('缓存图片至本地出现错误', e)
                reject(e)
            }
        })
    })
}
